﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
     <script src="../../Scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery.ui.js" type="text/javascript"></script>
    <script src="../../Scripts/repeater.js" type="text/javascript"></script>
    <script src="../../Scripts/pager.js" type="text/javascript"></script>
    <link href="../../Styles/pager.css" rel="stylesheet" type="text/css" />
     <script src="../js/jquery.query.js" type="text/javascript"></script>
     <style type="text/css" >
     .item{ width:600px; }
     </style>
</head>
<body>

<div class="item"><span class="title">[Name]</span><input type="checkbox" class="chkitem"  value="[Name]"/></div>
  <div id="pager" psize="50"></div>
  <div style="clear:left; width:400px; margin:0px auto;">
  <input type="button" value="确定" id="btn_sure" /><input type="button" value="关闭" id="btn_cancel" />
  <input type="hidden" value="" id="hidkeywords" />
  </div>

  <script type="text/javascript">
      $(function () {
          var $list = $(".item");
          //绑定列表方法
          var BindData = function () {
              $list.template({ autoBind: false });
              $.ajax({ url: "../AjaxHandler/TourismInfoTagList.ashx?t=" + new Date(),
                  data: {
                      pindex: 1,
                      psize: $("#pager").attr("psize"),
                      action: "List"
                  },
                  type: "post",
                  async: false,
                  success: function (data) {
                      pcount = data.Data.Pager.PageCount;
                      $("#pager").pager({ pagenumber: 1, pagecount: pcount, buttonClickCallback: PageClick });
                      $list.template("bindData", data.Data.Rows);
                  }
              });


          }
          BindData();
          //分页标签事件
          var PageClick = function (pageclickednumber) {

              $("#pager").pager({ pagenumber: pageclickednumber, pagecount: pcount, buttonClickCallback: PageClick });
              $.ajax({ url: "../AjaxHandler/TourismInfoTagList.ashx?t=" + new Date(),
                  data: {
                      pindex: pageclickednumber,
                      psize: $("#pager").attr("psize"),
                      action: "List"
                  },
                  type: "post",
                  async: false,
                  success: function (data) {
                      $list.template("bindData", data.Data.Rows);

                  }
              });
          }
          $list.delegate("input[type=checkbox]", "click", function () {
              if ($(this).attr("checked")) {
                  $("#hidkeywords").val($("#hidkeywords").val() + $(this).val() + ",");
              } else {
                  $("#hidkeywords").val($("#hidkeywords").val().replace($(this).val() + ","));
              }
          });
          $("#btn_sure").click(function () {
              $(this).parent().parent().parent().hide();
              var keywords = $("#hidkeywords").val();
              if (keywords.length > 0) {
                  $(this).parent().parent().parent().parent().find("#tags").val(keywords.substring(0,keywords.lastIndexOf(',')));
              }
          });
          $("#btn_cancel").click(function () {
              $(this).parent().parent().parent().hide();

          });
      })
    </script>
</body>
</html>
